//package com.geektime.hello.config;
//
//import com.zaxxer.hikari.HikariDataSource;
//import org.springframework.boot.autoconfigure.jdbc.DataSourceProperties;
//import org.springframework.boot.context.properties.ConfigurationProperties;
//import org.springframework.context.annotation.Bean;
//import org.springframework.context.annotation.Configuration;
//import org.springframework.context.annotation.Primary;
//import org.springframework.util.StringUtils;
//
//import javax.sql.DataSource;
//
//@Configuration
//public class DataSourceConfig {
//
//    @Primary
//    @Bean(name = "baseDataSourceProperties")
//    @ConfigurationProperties(prefix = "spring.datasource.base")
//    public DataSourceProperties baseDataSourceProperties() {
//        return new DataSourceProperties();
//    }
//
//    @Bean(name = "baseDataSource")
//    @ConfigurationProperties(prefix = "spring.datasource.base.hikari")
//    public DataSource baseDataSource() {
//        DataSourceProperties properties = this.baseDataSourceProperties();
//        return createHikariDataSource(properties);
//    }
//
//
//    @Bean(name = "quartzDataSourceProperties")
//    @ConfigurationProperties(prefix = "spring.datasource.quartz")
//    public DataSourceProperties quartzDataSourceProperties() {
//        return new DataSourceProperties();
//    }
//
//    @Bean(name = "quartzDataSource")
//    @ConfigurationProperties(prefix = "spring.datasource.quartz.hikari")
//    public DataSource quartzDataSource() {
//        DataSourceProperties properties = this.baseDataSourceProperties();
//        return createHikariDataSource(properties);
//    }
//
//    private static DataSource createHikariDataSource(DataSourceProperties properties) {
//        HikariDataSource dataSource = properties.initializeDataSourceBuilder().type(HikariDataSource.class).build();
//        if (StringUtils.hasText(properties.getName())) {
//            dataSource.setPoolName(properties.getName());
//        }
//        return dataSource;
//    }
//}
